package cn.cctvcc.core.enums.system;

import java.util.HashMap;
import java.util.Map;

/**
 * @description: 邮件类型枚举
 * @author: Jiang
 * @create: 2021-09-22 17:49
 */
public enum SysEmailTypeEnum {

    普通邮件("0", "普通邮件"),
    HTML邮件("1", "HTML邮件"),
    带图片的HTML邮件("2", "带图片的HTML邮件"),
    带附件的邮件("3", "带附件的邮件"),

    ;

    private final String code;
    private final String info;

    SysEmailTypeEnum(String code, String info) {
        this.code = code;
        this.info = info;
    }

    public static String getInfoByCode(String code) {
        SysEmailTypeEnum status = codeMap.get(code);
        if (status != null) {
            return status.getInfo();
        }
        return "未知状态";
    }

    public static String getCodeByInfo(String info) {
        SysEmailTypeEnum status = infoMap.get(info);
        if (status != null) {
            return status.getCode();
        }
        return "-";
    }

    private static Map<String, SysEmailTypeEnum> codeMap;

    private static Map<String, SysEmailTypeEnum> infoMap;
    static {
        codeMap = new HashMap<String, SysEmailTypeEnum>();
        infoMap = new HashMap<String, SysEmailTypeEnum>();
        for (SysEmailTypeEnum item : SysEmailTypeEnum.values()) {
            codeMap.put(item.getCode(), item);
            infoMap.put(item.getInfo(), item);
        }
    }

    public String getCode() {
        return code;
    }

    public String getInfo() {
        return info;
    }
}
